var searchParams;
		$(function(){
			//添加按钮事件
			$('#add').on('click', function() {
				
				var node = businessTable.datagrid('getSelected');
				if (node) {
						openedit('',node.businessId);
				} else {
					layer.msg('请选择一条商家！', {
						time : 1000
					})
				}
			});
			//修改按钮事件
			$('#edit').on('click', function() {
				var node = serviceConfig_table.datagrid('getSelected');
				if (node) {
					openedit(node.serviceConfigId);
				} else {
					layer.msg('请选择一条数据！', {
						time : 1000
					})
				}
			});
			//删除按钮事件
			$('#del').on('click', function() {
				del();
			});
			//查询按钮事件
			$('#search').on('click', function() {
				opensearch();
			});
		});
		//Table表格数据源
		var serviceConfig_table = $('#serviceConfig_table').datagrid(BasicData.createDatagrid({  
			url :'',
			frozenColumns:[[
				{field:'ck',checkbox:true},
				{title:'serviceConfigId',field:'serviceConfigId',hidden:true}
			]],
			columns:[[
				{field:'title',title:'名称',width:'10%',sortable:true,align:'center'},
				{field:'startHours',title:'开始的小时',width:'10%',sortable:true,align:'center'},
				{field:'endHours',title:'结束的小时',width:'10%',sortable:true,align:'center'},
				{field:'serviceFee',title:'服务费',width:'10%',sortable:true,align:'center'},
				{field:'sendFee',title:'配送费',width:'10%',sortable:true,align:'center'},
				{field:'agentFee',title:'代理费',width:'10%',sortable:true,align:'center'},
				{field:'platformFee',title:'平台费',width:'10%',sortable:true,align:'center'},
				{field:'note',title:'说明',width:'10%',sortable:true,align:'center'}
			]],
			onDblClickRow:function(rowIndex, rowData){
				
			}
		}));  
		//打开查询窗体
		function opensearch(){
			layer.open({
				title : '查询条件',
				type : 2,
				btn : ['查询','重置'],
				yes : function(index,layero) {
					var iframeWin = window[layero.find('iframe')[0]['name']];
					searchParams = iframeWin.$("#searchForm").serialize();
					var newparam = iframeWin.$("#searchForm").serializeJSON();
					$.extend(newparam,serviceConfig_table.queryParams);
					$('#data_table').datagrid('load',newparam);
					layer.close(index);
				},
				btn2 : function(index, layero) {
					var iframeWin = window[layero.find('iframe')[0]['name']];
					iframeWin.$("#searchForm").form("clear");
					return false;
				},
				area : [ '50%', '50%' ],
				content : rootpath + '/hhServiceConfig/toSearch.do?'+searchParams
			});
		}
		//编辑打开窗体
		function openedit(serviceConfigId,businessId){
			layer.open({
				title : '信息',
				type : 2,
				btn : ['保存','关闭'],
				yes : function(index,layero) {
					var iframeWin = window[layero.find('iframe')[0]['name']];
					iframeWin.$("#dataForm").submit();
				},
				btn2 : function(index, layero) {
				},
				area : [ '50%', '50%' ],
				content : rootpath + '/hhServiceConfig/toEdit.do?serviceConfigId='+serviceConfigId+"&businessId="+businessId
			});
		}
		//删除
		function del() {
			var node = serviceConfig_table.datagrid('getSelected');
			if (node) {
				layer.confirm('您确定要删除吗？', {
					btn : [ '确定', '取消' ]
				}, function(index, layero) {
				    layer.close(index);
					$.uitools.showLoading();//打开处理中遮罩层
					$.ajax({
						cache : true,
						type : "POST",
						url : rootpath + '/hhServiceConfig/delete.do',
						data : {
							serviceConfigId : node.serviceConfigId
						},
						error : function(request) {
							$.uitools.hideLoading();//关闭处理中遮罩层
							layer.msg('系统异常！', {
								icon : 2,
								time : 1000
							})
						},
						success : function(data) {
							$.uitools.hideLoading();//关闭处理中遮罩层
							if (data.code==0){
								layer.msg('删除成功！', {
									icon : 1,
									time : 1000
								}, function() {
									serviceConfig_table.datagrid('reload');
								})
							}else {
								layer.msg('删除异常！', {
									icon : 2,
									time : 1000
								})
							}
						}
					});
				}, function() {
				});
			} else {
				layer.msg('请选择一条数据！', {
					time : 1000
				})
			}
		}